<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script src="../node_modules/angular/angular.min.js"></script>
<!--	<script src="../dist/ocDialog.min.js"></script>-->

	<script src="../src/global.js"></script>

	<script src="../src/filter/gridAutoHeader.js"></script>
	<script src="../src/filter/gridMatrix.js"></script>
	<script src="../src/filter/throttle.js"></script>

	<script src="../src/directive/ocAddress.js"></script>
	<script src="../src/directive/ocAlert.js"></script>
	<script src="../src/directive/ocDialog.js"></script>
	<script src="../src/directive/ocFile.js"></script>
	<script src="../src/directive/ocGrid.js"></script>
	<script src="../src/directive/ocList.js"></script>
	<script src="../src/directive/ocListMenu.js"></script>
	<script src="../src/directive/ocTabs.js"></script>
	<script src="../src/directive/ocUpload.js"></script>
	<script src="../src/directive/ocDraggable.js"></script>
	<script src="../src/directive/ocResizable.js"></script>

	<script src="../src/prototype/dialogManager.js"></script>
	<script src="../src/prototype/dialogFactory.js"></script>
	<script src="../src/prototype/dialogInstance.js"></script>
	<script src="../src/prototype/draggable.js"></script>

	<script src="../src/service/ocDialog.js"></script>
	<script src="../src/service/ocDraggable.js"></script>
	<script src="../src/service/ocResizable.js"></script>

	<script src="../src/directive/switch/ocDialogClose.js"></script>
	<script src="../src/directive/switch/ocDialogOpen.js"></script>
	<script src="../src/directive/switch/ocDialogSizeMode.js"></script>
	<script src="../src/directive/switch/ocAlertOpen.js"></script>
	<script src="../src/directive/switch/ocFileOpen.js"></script>

<!-- Style sheets -->
	<link rel="stylesheet/less" href="../resources/less/style.less">
	<script src="../node_modules/less/dist/less.js"></script>

<!--	<link rel="stylesheet" href="../dist/style.css">-->


	<script>
	var app = angular.module("test", ['oc-dialog']);
	app.config(function (ocDialogProvider) {
		ocDialogProvider.config("ROUTE_PATH", "./dialog/");
		ocDialogProvider.config("BASE_Z_INDEX", 500);
	});
	app.run(function($templateCache){
		$templateCache.put('./dialog/cached.html', '<oc-dialog><div>cached</div></oc-dialog>');
	});
	app.controller('E', function($scope, ocDialog, ocDI, ocData) {
		var DI = ocDI;
		console.log(ocData);
		ocDI.setCloseButtonFn(ocData.b);
		console.log('ocDI是否工作正常：', DI === ocDI);
		$scope.menu =  [
		{
			title: '文件(F)',
			menu: [
				{
					title: '新建(N)',
					attr: 'ng-mousedown="fuck()"'
				},
				{
					title: '打开(O)',
					attr: 'oc-dialog-open="ccc"'
				},
				null,
				{
					title: '保存(S)'
				},
				{
					title: '另存为'
				},
				null,
				{
					title: '关闭探针(X)'
				}
			]
		},
		{
			title: '编辑(E)',
			menu: [
				{
					title: '撤销'
				},
				{
					title: '重复'
				},
				null,
				{
					title: '删除'
				},
				{
					title: '全部删除',
					attr: 'oc-alert-open="clearCase"'
				},
				null,
				{
					title: '向上插入',
					sub: [
						{
							title: '动作'
						},
						{
							title: '等待'
						},
						{
							title: '断言'
						}
					]
				},
				{
					title: '追加',
					sub: [
						{
							title: '动作'
						},
						{
							title: '等待'
						},
						{
							title: '断言'
						}
					]
				}
			]
		}];


		DI.setTitleButton('email', {
			icon: 'email',
			fn: function () {
				$scope.fuck3 = "fuck api";
			}
		}).setTitleButton('next', {
			icon: 'next',
			fn: function () {
				$scope.fuck3 = "fuck simulation";
			}
		});

		$scope.fuck555 = function () {
			console.log($scope.fuck3);
		};



		$scope.ocDialog = {
			title: "太牛逼了",
			isFull: false
		};

		$scope.fuck = function () {
			DI.$scope(function (scope) {
				$scope.fuck3 = scope.title;
				scope.title = 'shit!';
				if (scope.dataSet) {
					scope.dataSet.title = '儿子不服，改标题了';
				}
			});
		};

		$scope.hehe = function () {
			console.log($scope.ocDialog);
		};

		$scope.ccc= {
			name: "ccc",
			closed: function () {
				console.log('child has been closed!');
				$scope.fuck3 = "儿子死了";
			},
			dataSet: $scope.ocDialog
		}

		$scope.test2 = {
			title: "试试警告",
			message: "fsdfsfsdfsfsdfs",
			callFn: function () {
				console.log('警告结束');
			}
		}
	});
	app.controller('A', function($scope, ocDialog) {
		var assignment = [
			['one', 'two', 'three'],
			['foo', 'bar', 'baz'],
			['duang', 'duang', 'duang'],
			['1', '2', '3'],
			['infantry', 'artillery', 'horse'],
			['land', 'air', 'navy'],
			['魏', '蜀', '吴'],
			['1st', '2nd', '3rd'],
			['幽州', '并州', '冀州'],
			['青州', '兖州', '豫州'],
			['徐州', '雍州', '凉州'],
			['扬州', '荆州', '交州'],
			['益州', '司隶', '淮南']
		];
		$scope.hehe = function () {
			$scope.assignment = assignment;
		};
		$scope.gridCtrlTest = {
			header: [
				{
					text: "hehe1",
					width: 70
				},
				{
					text: "hehe2",
					width: 100
				},
				{
					text: "hehe3",
					width: 125
				},
				{
					text: "hehe3",
					width: 125
				}
			]
		};
		$scope.ListData = [
			{
				hhh: 'open',
				text: "hehe1",
				width: 70
			},
			{
				hhh: 'new',
				text: "hehe2",
				width: 100
			},
			{
				hhh: 'close',
				text: "hehe3",
				width: 125
			},
			{
				hhh: 'save',
				text: "hehe3",
				width: 125
			}
		];
		$scope.list = {
			se: -1
		};
		$scope.listOpt = {};

		$scope.listVisit = function (item, index, event) {
			data.text += 1;
			$scope.flag = !$scope.flag;
		}
		$scope.listSelect = function (item, index, event) {
			console.log(arguments);
		}
		$scope.listSelected = -1;

		$scope.ccc= {
			name: "ccc",
			share: function () {
				return assignment;
			},
			closeButtonFn: function () {
				console.log('Goodbye!');
			}
		}

		$scope.eee = function () {
			$scope.gridCtrlTest.header[0].text = "shit!";
			$scope.gridCtrlTest.header[0].width = 50;
		};


		$scope.fff = function () {
			$scope.gridCtrlTest.header.pop();
		};

		$scope.ddd = function () {
			ocDialog.file({
				action: "打开",
				title: "待测数据对象"
			});
		}

		$scope.checked = {};

		$scope.flag = true;
		$scope.cdf = function () {
			$scope.assignment[0][0] = '被改了'
		}
		$scope.fg = function () {
			$scope.flag = !$scope.flag;
		}
		$scope.fgc = function () {
			console.log('fgc');
		}
		$scope.tabControl = {
			selected: 0
		};
		$scope.tabIndex = function () {
			$scope.tabControl.selected = 2;
		}
		$scope.tabDis = function () {
			$scope.tabControl.$tabs[0].isDisabled = true;
		}
		$scope.tabEn = function () {
			$scope.tabControl.$tabs[0].isDisabled = false;
		}

		$scope.fileOpenData = [
			{name: '1', Time: Date.now()},
			{name: '2', Time: Date.now()},
			{name: '3', Time: Date.now()}
		];
		$scope.ffff = {
			share: function () {
				return $scope.fileOpenData;
			},
			action: "测试",
			actionFn: function (data) {
				console.log(this);
				console.log(arguments);
				this.closeDialog();
			},
			mapUpdatetime: 'Time'
		};

		$scope.alertOk = function (DI) {
			console.log('ok');
			console.log(DI);
		};
		$scope.alertCancel = function (DI) {
			console.log('cancel');
			console.log(DI);
		};
		$scope.alert = function () {
			ocDialog.alert({
				title: '我是服务版的警告标题',
				message: '服务配置的消息',
				okFn: $scope.alertOk,
				cancelFn: $scope.alertCancel
			});
		};
		$scope.fuckList = function () {
			console.log($scope.listOpt);
		}
		$scope.fuckChecked = function () {
			console.log($scope.checked);
		}
		$scope.action = function () {
			console.log(arguments);
		}
		$scope.fileData = [
			{
				name: 'ceshifdsfsd',
				other: "caoco",
				updateTime: 42342
			},
			{
				name: '11111',
				other: "caoco",
				updateTime: 42342
			},
			{
				name: 'ceshifdsfsd',
				other: "caoco",
				updateTime: 42342
			},
			{
				name: 'ceshifdsfsd',
				other: "caoco",
				updateTime: 42342
			},
			{
				name: 'ceshifdsfsd',
				other: "caoco",
				updateTime: 42342
			},
		];

		$scope.fileInit = function (DI, scope) {
			scope.data.push(			{
				name: 'init',
				other: "caoco",
				updateTime: 423424242
			});
		}

		$scope.openFn = function () {
			console.log('hello');
		}

		$scope.fuck = function () {
			console.log(2324);
		};
	});
	</script>
</head>
<body ng-app="test" ng-controller="A">
	<oc-menu>
		<li>文件
			<ul>
				<li ng-click="fuck()">shishi</li>
				<li class="sub">新建
					<ul>
						<li ng-click="fuck()">shishi</li>
						<li ng-click="fuck()">shishi</li>
						<hr/>
						<li ng-click="fuck()">shishi</li>
						<li ng-click="fuck()">shishi</li>
					</ul>
				</li>
			</ul>
		</li>
	</oc-menu>
	<a oc-dialog-open="{name:'ccc',data:{a:1,b:alert}}">打开新窗口</a><hr/>
	<a href oc-dialog-open="{name: 'cached'}">打开缓存窗口</a><hr/>
	<a oc-file-open="{title:'测试用例',actionName:'测试',
		actionFn:action,data:fileData,toolbar:[
			{icon:'open',fn:openFn},
			{icon:'save',fn:openFn}
		]}">指令打开文件</a>
	<a ng-click="ddd()">服务打开文件</a><hr/>
	<a ng-click="eee()">改列头</a>
	<a ng-click="fff()">删列头</a>
	<a ng-click="gridCtrlTest.header=[]">清空列头</a>
	<a ng-click="hehe()">加数据</a>
	<a ng-click="fg()">刷新</a>
	<a ng-click="cdf()">改数据</a><hr/>
	<a ng-click="tabIndex()">改选项卡激活2</a>
	<a ng-click="tabDis()">禁用选项卡0</a>
	<a ng-click="tabEn()">解禁选项卡0</a>
	{{gridCtrlTest.$position.row}}
	{{gridCtrlTest.$position.col}}
	{{listCtrlTest.selected}}<hr/>
	<a oc-alert-open="">默认Alert</a>
	<a ng-click="alert()">服务配置的Alert</a>
	<a oc-alert-open="{title:'使用了警告功能',
		message:'显示了警告信息',
		okFn:alertOk,
		cancelFn:alertCancel}">满配置的Alert</a><hr/>
	<a ng-click="fuckList()">输出list控制对象到控制台</a>
	<a ng-click="fuckChecked()">输出listChecked到控制台</a>

	<oc-grid style="width:400px;height:500px;left:1rem;bottom:2rem;border:1px solid #ccc;"
		oc-grid-data="assignment" oc-grid-refresh="flag"
		oc-grid-control="gridCtrlTest"></oc-grid>

	<oc-list style="width:400px;height:300px;right:2rem;top:22rem;">
		<oc-row ng-repeat="a in ListData"
<!--			ng-click="list.se=$index"-->
			ng-class="{active:list.se===$index}">
			<oc-col width="40" label="" locked><input type="checkbox" /></oc-col>
			<oc-col width="120" label="test"><b>{{a.text}}</b></oc-col>
			<oc-col label="sb" width="80">fdsfasdf</oc-col>
		</oc-row>
	</oc-list>
<!--
	<oc-list oc-list-data="gridCtrlTest.header"
		oc-list-selected="listSelected"
		oc-list-refresh="flag"
		oc-list-checked="checked"
		style="border:1px solid #ccc;width:400px;height:300px;right:23rem;top:22rem;"></oc-list>

-->
<!--
	<oc-list oc-list-data="gridCtrlTest.header"
		oc-list-selected="listSelected"
		oc-list-refresh="flag"
		style="border:1px solid #ccc;width:400px;height:300px;left:23rem;bottom:1rem;"></oc-list>
-->

	<oc-tab-set oc-tab-control="tabControl" style="width:20rem;height:20rem;left:50%;top:0;">
		<oc-tab di oc-tab-title="简单视图" oc-tab-active-fn="fgc">
			<oc-upload style="width:4rem;height:1.1rem;">bythyt</oc-upload>
			<fieldset class="oc-legend" style="top:2rem;left:0.3rem;right:0.3rem;
			bottom:0.3rem;">
				<legend>legrnd用法</legend>
				<button style="top:0.8rem;left:0;">测试按钮</button>
				<button style="left:5rem;">默认4.3rem</button>
				<button disabled style="left:10rem;">disabled</button>
				<button style="top:3rem;"></button>
				<button class="ico open" style="top:3rem;left:5rem"></button>
				<button disabled class="ico close" style="top:3rem;left:7rem"></button>\
				<input type="text" class="search" style="right:0;top:4rem;">
				<input type="text" class="filter" style="right:0;top:6rem;">
			</fieldset>
		</oc-tab>
		<oc-tab oc-tab-title="交互编码"></oc-tab>
		<oc-tab oc-tab-title="源码"></oc-tab>
		<oc-tab oc-tab-title="test"></oc-tab>
	</oc-tab-set>
<!--
	<div ng-controller="A">
		{{ett.ocDialog.title}}
	</div>
-->
</body>
</html>
